package com.saturday.common.support;

import com.saturday.common.model.HeaderContext;

public class HeaderContextHolder {

    private static final ThreadLocal<HeaderContext> headerContextThreadLocal = new ThreadLocal<>();

    public static HeaderContext get() {
        HeaderContext headerContext = headerContextThreadLocal.get();
        if (null == headerContext) {
            throw new RuntimeException("header上下文信息不存在！");
        }
        return headerContext;
    }

    public static void set(HeaderContext headerContext) {
        headerContextThreadLocal.set(headerContext);
    }

    public static void clear() {
        headerContextThreadLocal.remove();
    }
}
